function varargout = Decipher_Tool(varargin)
% DECIPHER_TOOL M-file for Decipher_Tool.fig
%      DECIPHER_TOOL, by itself, creates a new DECIPHER_TOOL or raises the existing
%      singleton*.
%
%      H = DECIPHER_TOOL returns the handle to a new DECIPHER_TOOL or the handle to
%      the existing singleton*.
%
%      DECIPHER_TOOL('CALLBACK',hObject,eventData,handles,...) calls the
%      local
%      function named CALLBACK in DECIPHER_TOOL.M with the given input arguments.
%
%      DECIPHER_TOOL('Property','Value',...) creates a new DECIPHER_TOOL or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Decipher_Tool_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Decipher_Tool_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help Decipher_Tool

% Last Modified by GUIDE v2.5 31-May-2008 19:02:11

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Decipher_Tool_OpeningFcn, ...
                   'gui_OutputFcn',  @Decipher_Tool_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before Decipher_Tool is made visible.
function Decipher_Tool_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to Decipher_Tool (see VARARGIN)

% Choose default command line output for Decipher_Tool
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes Decipher_Tool wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = Decipher_Tool_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;
handles.Pic = imread('Default.jpg'); %Original Picture
handles.BW_Pic = rgb2gray(handles.Pic); %BW of Original Picture
handles.RegionMap = im2uint8(zeros(size(handles.Pic))); %The Regional Map we'll create
handles.PrevRegionMap = handles.RegionMap; %Backup image, in case we'll want to roll back a step
handles.MapOnImage = handles.Pic; %Image for viewing Map on BW pic
handles.PrevMapOnImage = handles.MapOnImage;
handles.IndexedMap = im2uint8(zeros(size(handles.BW_Pic))); %For output
handels.PrevIndexedMap = handles.IndexedMap;

handles.color_image = imread('color_tab.jpg');
axes(handles.color_pic);
imshow(handles.color_image);

handles.legend = cell(4,1);
handles.legend{1}='Sky';
handles.legend{2}='Building Walls and Trees';
handles.legend{3}='Building Roofs';
handles.legend{4}='Ground';   

handles.LabelingModelStruct = struct; % The temp model struct for labeling is 0 for now
handles.LabelingModelStruct.exists = 0;

guidata(hObject,handles) %Creating Pic data object
axes(handles.ImagePic);
image(handles.Pic)

% --- Executes on button press in OpenFile.
function OpenFile_Callback(hObject, eventdata, handles)
% hObject    handle to OpenFile (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
clc;
[filename, pathname] = uigetfile({'*.mat';'*.jpg';'*.*'},'Pick a JPG or MAT file');
if isequal(filename,0)
    disp('User selected Cancel')
else
    file = fullfile(pathname, filename)
    disp(['User selected', file])
    jpg_check = findstr('.jpg',filename);
    jpg_check2= findstr('.JPG',filename);
    mat_check = findstr('.mat',filename) ;
    mat_check2= findstr('.MAT',filename);
    if ((size(jpg_check,1)~=0)| ( size(jpg_check2,1)~=0) )%We open new jpg picture
        handles.Pic = imread(file);
        handles.BW_Pic = rgb2gray(imread(file)); %BW of Original Picture
        handles.MapOnImage = handles.Pic; 
        handles.PrevMapOnImage = handles.MapOnImage;
        handles.RegionMap = im2uint8(zeros(size(handles.Pic))); %The Regional Map we'll create
        handles.RegionMap(:,:,3)=143;
        handles.PrevRegionMap = handles.RegionMap;
        handles.IndexedMap = im2uint8(zeros(size(handles.BW_Pic))); %For output
        handels.PrevIndexedMap = handles.IndexedMap;
        guidata(hObject,handles);%Updating data object
        axes(handles.ImagePic);
        image(handles.Pic);
    end
    if ((size(mat_check,1)~=0) | (size(mat_check2,1)~=0)) %We reopen mat file
        tmp_struct = open(file);
        handles.Pic = tmp_struct.saved_data{3,1};
        handles.BW_Pic = rgb2gray(tmp_struct.saved_data{3,1});
        handles.IndexedMap = tmp_struct.saved_data{2,1};%For output
        handles.PrevIndexedMap = handles.RegionMap;
%         rgb_val_1=[145,180,210];
%         rgb_val_2=[100,105,125];
%         rgb_val_3=[100,80,75];
%         rgb_val_4=[180,165,150];   
        rgb_val_1=[0,143,255];
        rgb_val_2=[143,255,112];
        rgb_val_3=[255,112,0];
        rgb_val_4=[128,0,0];   
        mask_1 = uint8(handles.IndexedMap==1);
        mask_2 = uint8(handles.IndexedMap==2);
        mask_3 = uint8(handles.IndexedMap==3);
        mask_4 = uint8(handles.IndexedMap==4);
        mask_0 = uint8(handles.IndexedMap==0);
        handles.RegionMap = im2uint8(zeros(size(handles.Pic))); 
        handles.RegionMap(:,:,1) = im2uint8(zeros(size(handles.BW_Pic))) + mask_1*rgb_val_1(1) + mask_2*rgb_val_2(1) + mask_3*rgb_val_3(1) + mask_4*rgb_val_4(1);
        handles.RegionMap(:,:,2) = im2uint8(zeros(size(handles.BW_Pic))) + mask_1*rgb_val_1(2) + mask_2*rgb_val_2(2) + mask_3*rgb_val_3(2) + mask_4*rgb_val_4(2);
        handles.RegionMap(:,:,3) = im2uint8(zeros(size(handles.BW_Pic))) + mask_1*rgb_val_1(3) + mask_2*rgb_val_2(3) + mask_3*rgb_val_3(3) + mask_4*rgb_val_4(3);
        handles.PrevRegionMap = handles.RegionMap;
        handles.MapOnImage = im2uint8(zeros(size(handles.Pic))); 
        handles.MapOnImage(:,:,1) = mask_0.*handles.Pic(:,:,1) +  mask_1*rgb_val_1(1) + mask_2*rgb_val_2(1) + mask_3*rgb_val_3(1) + mask_4*rgb_val_4(1);
        handles.MapOnImage(:,:,2) = mask_0.*handles.Pic(:,:,2) +  mask_1*rgb_val_1(2) + mask_2*rgb_val_2(2) + mask_3*rgb_val_3(2) + mask_4*rgb_val_4(2);
        handles.MapOnImage(:,:,3) = mask_0.*handles.Pic(:,:,3) +  mask_1*rgb_val_1(3) + mask_2*rgb_val_2(3) + mask_3*rgb_val_3(3) + mask_4*rgb_val_4(3);
        handles.PrevMapOnImage = handles.MapOnImage;
        guidata(hObject,handles);%Updating data object
        axes(handles.ImagePic);
        image(handles.Pic);
    end
end

% --- Executes on button press in SaveFile.
function SaveFile_Callback(hObject, eventdata, handles)
% hObject    handle to SaveFile (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
[filename, pathname] = uiputfile('*.mat', 'Save As MAT file');
if isequal(filename,0) | isequal(pathname,0)
    disp('User selected Cancel')
else
    file = fullfile(pathname,filename);
    disp(['User selected: ',file]);
    
    saved_data = cell(3,1);
    saved_data{1} = handles.legend;
    saved_data{2} = handles.IndexedMap; %Indexed Map
    saved_data{3} = handles.Pic; %Original RGB Picture
    save (filename,'saved_data');
end

% --- Executes on button press in Index_on_off.
function Index_on_off_Callback(hObject, eventdata, handles)
% hObject    handle to Index_on_off (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
sz = size(handles.MapOnImage);

while (get(hObject,'Value')== get(handles.Index_on_off,'Max')) % toggle button is pressed
    axes(handles.ImagePic);
    image(handles.MapOnImage);    
    [xx,yy] = getline(handles.ImagePic);
    xx = floor(xx);
    yy = floor(yy);
    xx(find(xx<1))=1;
    yy(find(yy<1))=1;
    xx(find(xx>sz(2)))=sz(2);
    yy(find(yy>sz(1)))=sz(1);

    tmp_poly = poly2mask(xx,yy,sz(1),sz(2));
    val = get(handles.Regions_List,'Value');
    if (val==5)
        val = 0; % The region is cleared, need to put 0 to region map
    end
    rgb_val = [0,0,143];        
    switch val
      case 1  % 1 - Sky  
            rgb_val=[0,143,255];
        case 2 % 2 - Building Walls and Tees
            rgb_val=[143,255,112];
        case 3  % 3 - Building Roofs   
            rgb_val=[255,112,0];
        case 4  % 4 - Ground   
            rgb_val=[128,0,0];   
        otherwise % 5 - Clearing Region 
            rgb_val=[0,0,143];  
    end %of switch
     
    poly_ind=find(tmp_poly>0);
    
    imR = handles.MapOnImage(:,:,1);
    imG = handles.MapOnImage(:,:,2);
    imB = handles.MapOnImage(:,:,3);
    if (val~=0) %adding new information
        imR(poly_ind)=rgb_val(1);
        imG(poly_ind)=rgb_val(2);
        imB(poly_ind)=rgb_val(3);
        handles.MapOnImage=cat(3,imR,imG,imB);
    else % returning this region to original image
        original_R = handles.Pic(:,:,1);
        original_G = handles.Pic(:,:,2);
        original_B = handles.Pic(:,:,3);
        imR(poly_ind)=original_R(poly_ind);
        imG(poly_ind)=original_G(poly_ind);
        imB(poly_ind)=original_B(poly_ind);
        handles.MapOnImage=cat(3,imR,imG,imB);
    end
    imR = handles.RegionMap(:,:,1);
    imR(poly_ind)=rgb_val(1);
    imG = handles.RegionMap(:,:,2);
    imG(poly_ind)=rgb_val(2);
    imB = handles.RegionMap(:,:,3);
    imB(poly_ind)=rgb_val(3);
    handles.RegionMap = cat(3,imR,imG,imB);
  
    handles.IndexedMap(poly_ind) = val;
    
    image(handles.MapOnImage);        
end %of while
guidata(hObject,handles); %Updating data object

% --- Executes on button press in Backup.
function Backup_Callback(hObject, eventdata, handles)
% hObject    handle to Backup (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.PrevRegionMap = handles.RegionMap; %Backup image, in case we'll want to roll back a step
handles.PrevMapOnImage = handles.MapOnImage;
handles.PrevIndexedMap = handles.IndexedMap;
guidata(hObject,handles) %Updating data object


% --- Executes on button press in UndoBackup.
function UndoBackup_Callback(hObject, eventdata, handles)
% hObject    handle to UndoBackup (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.RegionMap = handles.PrevRegionMap; %Roll back, in case we've made a mistake
handles.MapOnImage = handles.PrevMapOnImage;
handles.IndexedMap = handles.PrevIndexedMap;
guidata(hObject,handles); %Updating data object
val = get(handles.ImageDisplayMenu,'Value');
if (val == 3 ) % Update display if needed
    axes(handles.ImagePic);
    colormap('default');
    image(handles.RegionMap);  
end
if (val == 4 )  % Update display if needed
    axes(handles.ImagePic);
    colormap('default');
    image(handles.MapOnImage);  
end

% --- Executes on selection change in Regions_List.
function Regions_List_Callback(hObject, eventdata, handles)
% hObject    handle to Regions_List (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns Regions_List contents as cell array
%        contents{get(hObject,'Value')} returns selected item from Regions_List
val = get(handles.Regions_List,'Value');     
    
rgb_val = [0,0,0];  
    switch val
        case 1  % 1 - Sky  
            rgb_val=[0,143,255];
        case 2 % 2 - Building Walls and Trees 
            rgb_val=[143,255,112];
        case 3  % 3 - Building Roofs   
            rgb_val=[255,112,0];        
        case 4 % 4 - Ground   
            rgb_val=[128,0,0];       
        otherwise  % 5 - Clearing Region
            rgb_val=[0,0,143];       
    end %of switch
    
    handles.color_image(:,:,1)= rgb_val(1);
    handles.color_image(:,:,2)= rgb_val(2);
    handles.color_image(:,:,3)= rgb_val(3);
    axes(handles.color_pic);
    imshow(handles.color_image);

% --- Executes during object creation, after setting all properties.
function Regions_List_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Regions_List (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: listbox controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in zoom_on_off.
function zoom_on_off_Callback(hObject, eventdata, handles)
% hObject    handle to zoom_on_off (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
axes(handles.ImagePic);
if (get(handles.zoom_on_off,'Value')== get(handles.zoom_on_off,'Min')) % Returning to original size   
    zoom off;
else % Activating Zoom
    zoom on;
end

% --- Executes on button press in Zoom_Out.
function Zoom_Out_Callback(hObject, eventdata, handles)
% hObject    handle to Zoom_Out (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
axes(handles.ImagePic);
 zoom out;
 
% --- Executes on selection change in DisplayOptions.
function DisplayOptions_Callback(hObject, eventdata, handles)
% hObject    handle to DisplayOptions (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns DisplayOptions contents as cell array
%        contents{get(hObject,'Value')} returns selected item from DisplayOptions
if (get(handles.Index_on_off,'Value')== get(handles.Index_on_off,'Min')) % toggle button is not pressed
    val = get(hObject,'Value');
    axes(handles.ImagePic);
    switch val
    case 1
        colormap('default');
        image(handles.Pic);
    case 2
      colormap('gray');
      imagesc(handles.BW_Pic);
    case 3
        colormap('default');
        image(handles.MapOnImage);
    otherwise %case 4
        colormap('default');
        image(handles.RegionMap);
    end
end % We change display, only when On_OFF button isn't pressed

% --- Executes during object creation, after setting all properties.
function DisplayOptions_CreateFcn(hObject, eventdata, handles)
% hObject    handle to DisplayOptions (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: listbox controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in OpenLabelingImage.
function OpenLabelingImage_Callback(hObject, eventdata, handles)
% hObject    handle to OpenLabelingImage (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in OpenLabelingModel.
function OpenLabelingModel_Callback(hObject, eventdata, handles)
% hObject    handle to OpenLabelingModel (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

[filename, pathname] = uigetfile({'*.mat'},'Pick a MAT file - labeling model only');
if isequal(filename,0)
    disp('User selected Cancel')
else
    file = fullfile(pathname, filename)
    disp(['User selected model', file])
    temp_struct = open(file);
    handles.LabelingModelStruct.model = temp_struct.models_struct;
  %  handles.LabelingModelStruct.model =  open(file);
    handles.LabelingModelStruct.exists = 1;
    guidata(hObject,handles);%Updating data object
end

% --- Executes on button press in RunLabeling.
function RunLabeling_Callback(hObject, eventdata, handles)
% hObject    handle to RunLabeling (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if (handles.LabelingModelStruct.exists== 0)
        disp(['User tried to label an image without loading a model'])
else
    
    gui_params = struct;
    gui_params.class_func = 0;
    gui_params.segment_voting_style = 0;
    gui_params.hypo_amount = 0;
    gui_params.reg_per_hypo = 0;
    
    %options - 'FLD' 'KNN' 'RealAdaBoost' 'ModestAdaBoost'
    val = get(handles.ClassFunc ,'Value');     
    switch val
        case 1 %'FLD'
            gui_params.class_func= 'FLD';       
        case 2 %'KNN' 
            gui_params.class_func= 'KNN';
        case 3 %'Ada Boost Real' 
            gui_params.class_func= 'RealAdaBoost';
        case 4 %'Ada Boost Modest' 
            gui_params.class_func= 'ModestAdaBoost';
    end
    disp(['gui_params.region_voting_style = ',gui_params.class_func])
    
    val = get(handles.SegVoteStyle ,'Value');     
    switch val
        case 1 %'Polling'
            gui_params.segment_voting_style= 'polling';       
        case 2 %'Max Value'
            gui_params.segment_voting_style= 'max_value';
        case 3 %'Sum Value' 
            gui_params.segment_voting_style= 'sum_value';
    end
    disp(['gui_params.segment_voting_style = ',gui_params.segment_voting_style])
    
    val = get(handles.HypotheseNumForConfig ,'Value');    
    switch val
        case 1 % '1'
            gui_params.hypo_amount = 1;
        case 2 % '2'
            gui_params.hypo_amount = 2;
        case 3 % '3'
            gui_params.hypo_amount = 3;
        case 4 % '4'
            gui_params.hypo_amount = 4;
        case 5 % '5'
            gui_params.hypo_amount = 5;
        case 6 %'10'
            gui_params.hypo_amount = 10;
    end
    disp(['gui_params.hypo_amount = ',num2str(gui_params.hypo_amount)])

    val = get(handles.RegNumArray ,'Value');    
    switch val
        case 1 % '[3 5 7]'
            gui_params.reg_per_hypo = [3, 5 ,7];
        case 2 % '[5 10 15]'
            gui_params.reg_per_hypo = [5, 10, 15];
        case 3 % '[15 20 25]'
            gui_params.reg_per_hypo = [15, 20, 25];
        case 4 % '[20 25 30]'
            gui_params.reg_per_hypo= [20,25,30];
    end
    disp(['gui_params.reg_per_hypo = ',num2str(gui_params.reg_per_hypo)])
     
    gui_params.norm_flag_seg='uniform';
    gui_params.norm_flag_reg='uniform';
    gui_params.hypo_option='distance';
    gui_params.norm_prob='false';                                   

    [Results]=image_labels(handles.Pic, handles.LabelingModelStruct.model,gui_params);
   
    handles.IndexedMap = Results.segment_labels_map;%For output
    disp(['The Grade of the Output is = ', num2str(Results.labeling_grade)])
    handles.GradeWindow = num2str(Results.labeling_grade);
    
    % Updating display matrixes
    rgb_val_1=[0,143,255];
    rgb_val_2=[143,255,112];
    rgb_val_3=[255,112,0];
    rgb_val_4=[128,0,0];   
    mask_1 = uint8(handles.IndexedMap==1);
    mask_2 = uint8(handles.IndexedMap==2);
    mask_3 = uint8(handles.IndexedMap==3);
    mask_4 = uint8(handles.IndexedMap==4);
    mask_0 = uint8(handles.IndexedMap==0);
    handles.RegionMap = im2uint8(zeros(size(handles.Pic))); 
    handles.RegionMap(:,:,1) = im2uint8(zeros(size(handles.BW_Pic))) + mask_1*rgb_val_1(1) + mask_2*rgb_val_2(1) + mask_3*rgb_val_3(1) + mask_4*rgb_val_4(1);
    handles.RegionMap(:,:,2) = im2uint8(zeros(size(handles.BW_Pic))) + mask_1*rgb_val_1(2) + mask_2*rgb_val_2(2) + mask_3*rgb_val_3(2) + mask_4*rgb_val_4(2);
    handles.RegionMap(:,:,3) = im2uint8(zeros(size(handles.BW_Pic))) + mask_1*rgb_val_1(3) + mask_2*rgb_val_2(3) + mask_3*rgb_val_3(3) + mask_4*rgb_val_4(3);
    handles.MapOnImage = im2uint8(zeros(size(handles.Pic))); 
    handles.MapOnImage(:,:,1) = mask_0.*handles.Pic(:,:,1) +  mask_1*rgb_val_1(1) + mask_2*rgb_val_2(1) + mask_3*rgb_val_3(1) + mask_4*rgb_val_4(1);
    handles.MapOnImage(:,:,2) = mask_0.*handles.Pic(:,:,2) +  mask_1*rgb_val_1(2) + mask_2*rgb_val_2(2) + mask_3*rgb_val_3(2) + mask_4*rgb_val_4(2);
    handles.MapOnImage(:,:,3) = mask_0.*handles.Pic(:,:,3) +  mask_1*rgb_val_1(3) + mask_2*rgb_val_2(3) + mask_3*rgb_val_3(3) + mask_4*rgb_val_4(3);
    
    guidata(hObject,handles);%Updating data object
end


% --- Executes on selection change in ClassFunc.
function ClassFunc_Callback(hObject, eventdata, handles)
% hObject    handle to ClassFunc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns ClassFunc contents as cell array
%        contents{get(hObject,'Value')} returns selected item from ClassFunc


% --- Executes during object creation, after setting all properties.
function ClassFunc_CreateFcn(hObject, eventdata, handles)
% hObject    handle to ClassFunc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on selection change in SegVoteStyle.
function SegVoteStyle_Callback(hObject, eventdata, handles)
% hObject    handle to SegVoteStyle (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns SegVoteStyle contents as cell array
%        contents{get(hObject,'Value')} returns selected item from SegVoteStyle


% --- Executes during object creation, after setting all properties.
function SegVoteStyle_CreateFcn(hObject, eventdata, handles)
% hObject    handle to SegVoteStyle (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end




% --- Executes during object creation, after setting all properties.
function color_pic_CreateFcn(hObject, eventdata, handles)
% hObject    handle to color_pic (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: place code in OpeningFcn to populate color_pic




% --- Executes on selection change in HypotheseNumForConfig.
function HypotheseNumForConfig_Callback(hObject, eventdata, handles)
% hObject    handle to HypotheseNumForConfig (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns HypotheseNumForConfig contents as cell array
%        contents{get(hObject,'Value')} returns selected item from HypotheseNumForConfig


% --- Executes during object creation, after setting all properties.
function HypotheseNumForConfig_CreateFcn(hObject, eventdata, handles)
% hObject    handle to HypotheseNumForConfig (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on selection change in RegNumArray.
function RegNumArray_Callback(hObject, eventdata, handles)
% hObject    handle to RegNumArray (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns RegNumArray contents as cell array
%        contents{get(hObject,'Value')} returns selected item from RegNumArray


% --- Executes during object creation, after setting all properties.
function RegNumArray_CreateFcn(hObject, eventdata, handles)
% hObject    handle to RegNumArray (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end





function GradeWindow_Callback(hObject, eventdata, handles)
% hObject    handle to GradeWindow (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of GradeWindow as text
%        str2double(get(hObject,'String')) returns contents of GradeWindow as a double


% --- Executes during object creation, after setting all properties.
function GradeWindow_CreateFcn(hObject, eventdata, handles)
% hObject    handle to GradeWindow (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


